{% comment %}
<!--
  Copyright (C) 2008 ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
  - http://heavyz.blogspot.com/
  - http://buggarden.blogspot.com/

  The restaurant's rating section.
  
  Created on 2008-10-16.
  $Id: resto_rating.html 271 2008-11-10 14:43:10Z heavyzheng $
-->
{% endcomment %}

<div id="resto_rating" class="section">

  {% if error %}
    <div class="error message">
      {{ error }}
      <a href="javascript:void(0);" onclick="closeMessage('#resto_rating')">[close]</a>
    </div>
  {% endif %}

  <script type="text/javascript">//<![CDATA[
  
  function showRatingDetails() {
      $("#resto_rating .show-details").hide();
      $("#resto_rating .hide-details").show();
      $("#resto_rating .details"     ).show("slow");
  }
  
  function hideRatingDetails() {
      $("#resto_rating .hide-details").hide();
      $("#resto_rating .show-details").show();
      $("#resto_rating .details"     ).hide("slow");
  }
  
  function addRatingDesc() {
      $(".rating_1").text("Poor");
      $(".rating_2").text("Nothing special");
      $(".rating_3").text("Worth going");
      $(".rating_4").text("Pretty good");
      $(".rating_5").text("Excellent");
  }
  
  //]]></script>
  
  <div class="rating-box">
  
    {% if resto.ratings %}
    
      <div class="average">
        <b>Rating:</b>
        {% for star in resto.average_stars %}
          <img src="/static/fnr/images/small_star_{{ star }}.gif" alt="{{ star }}"/>
        {% endfor %}
        <b><span class="rating_{{ resto.average_int }}"></span></b>
        ({{ resto.average|floatformat:2 }} out of 5, based on {{ resto.ratings }} ratings)
        <small>
          <a class="show-details" href="javascript:void(0);" onclick="showRatingDetails();">[show details]</a>
          <a class="hide-details hidden" href="javascript:void(0);" onclick="hideRatingDetails();">[hide details]</a>
        </small>
      </div><!--/.average-->
      
      <div class="details hidden">
      
        <table class="noborder">
          <tr>
            <td class="nowrap" width="1%">Cuisine:</td>
            <td class="nowrap" width="49%">
              {% for star in resto.cuisine_stars %}
                <img src="/static/fnr/images/small_star_{{ star }}.gif" alt="{{ star }}"/>
              {% endfor %}
              <small>
                <span class="rating_{{ resto.cuisine_int }}"></span>
                ({{ resto.cuisine|floatformat:2 }} out of 5)
              </small>
            </td>
          </tr>
          <tr>
            <td class="nowrap" width="1%">Economy:</td>
            <td class="nowrap" width="49%">
              {% for star in resto.economy_stars %}
                <img src="/static/fnr/images/small_star_{{ star }}.gif" alt="{{ star }}"/>
              {% endfor %}
              <small>
                <span class="rating_{{ resto.economy_int }}"></span>
                ({{ resto.economy|floatformat:2 }} out of 5)
              </small>
            </td>
          </tr>
          <tr>
            <td class="nowrap" width="1%">Service:</td>
            <td class="nowrap" width="49%">
              {% for star in resto.service_stars %}
                <img src="/static/fnr/images/small_star_{{ star }}.gif" alt="{{ star }}"/>
              {% endfor %}
              <small>
                <span class="rating_{{ resto.service_int }}"></span>
                ({{ resto.service|floatformat:2 }} out of 5)
              </small>
            </td>
          </tr>
        
        </table>
      
      </div><!--/.details-->
    
    {% else %}
      
      <div class="average">
        This resto doesn't have any rating at this moment.
      </div><!--/.average-->
    
    {% endif %}{# resto.ratings #}
    
  </div><!--/.rating-box-->
  
  <script type="text/javascript">//<![CDATA[
  addRatingDesc();
  //]]></script>
  
  
  {% if user_ratings %}
    <div>
      #TODO: Your ratings:<br/>
      Cuisine: {{ user_ratings.cuisine }}<br/>
      Economy: {{ user_ratings.economy }}<br/>
      Service: {{ user_ratings.service }}<br/>
    </div>
  {% endif %}{# user_ratings #}

</div><!--/#resto_rating-->

